package com.tencent.sr.iris.activity.interfaces.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.tencent.sr.rmall.common.exception.TMallBizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 邀请有礼数据版本
 */
@Getter
@AllArgsConstructor
public enum InviteGiftVersionEnum {
    BEFORE_V0621("0", "0621版本之前", null, 1687276799000l),

    V0621("1", "0621版本", 1687276800000l, 1688140799000l),

    V0706("2", "0706版本", 1688140800000l, null),

    ;

    @JsonValue
    private final String code;

    private final String desc;

    private final Long startTime;

    private final Long endTime;


    public static InviteGiftVersionEnum getByCode(String code) {
        for (InviteGiftVersionEnum staff : InviteGiftVersionEnum.values()) {
            if (staff.getCode().equals(code)) {
                return staff;
            }
        }

        return null;
    }

    @JsonCreator
    public static InviteGiftVersionEnum jsonCreator(String code) {
        InviteGiftVersionEnum activityIdEnum = getByCode(code);
        if (activityIdEnum == null) {
            throw new TMallBizException("邀请有礼数据版本错误");
        }
        return activityIdEnum;
    }
}
